using SMGCore;
using UnityEngine;

namespace Game.Networking {
	public sealed class EntityObjectFactory : ManualSingleton<EntityObjectFactory> {
		public ShipCore             ShipPrefab;
		public CargoContainer       CargoContainerPrefab;
		public SingleChunkProcessor AsteroidPrefab;
		public TeamBase             BasePrefab;
		public SecurityTurret       SecurityTurretPrefab;
		public Missile              MissilePrefab;

		public Entity CreateEntityObject(EntityType type, Vector3 position, Vector3 rotation) {
			switch ( type ) {
				case EntityType.Unknown:
					return null;
				case EntityType.Ship:
					var ship = Instantiate(ShipPrefab);
					ship.transform.position = position;
					ship.transform.rotation = Quaternion.Euler(rotation);
					return ship;
				case EntityType.BlockGrid:
					var grid = Instantiate(AsteroidPrefab);
					grid.transform.position = position;
					grid.transform.rotation = Quaternion.Euler(rotation);
					return grid;
				case EntityType.CargoContainer:
					var cargo = Instantiate(CargoContainerPrefab);
					cargo.transform.position = position;
					cargo.transform.rotation = Quaternion.Euler(rotation);
					return cargo;
				case EntityType.TeamBase:
					var b = Instantiate(BasePrefab);
					b.transform.position = position;
					b.transform.rotation = Quaternion.Euler(rotation);
					return b;
				case EntityType.Projectile:
					var m = Instantiate(MissilePrefab);
					m.transform.position = position;
					m.transform.rotation = Quaternion.Euler(rotation);
					return m;
				case EntityType.SecurityTurret:
					var turret = Instantiate(SecurityTurretPrefab);
					turret.transform.position = position;
					turret.transform.rotation = Quaternion.Euler(rotation);
					return turret;
				default:
					return null;
			}

		}
	}
}
